package com.xiaoming.api;

import com.xiaoming.bean.Result;
import com.xiaoming.service.OOSService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.ServletResponse;

@RestController
@RequestMapping("/oos")
public class OOSController {
    @Autowired
    private OOSService oosService;

    @PostMapping("/upload")
    public Result upload(@RequestParam("file")MultipartFile file){
        return oosService.upload(file);
    }


    @GetMapping("/download")
    public void download(@RequestParam("name")String fileName, ServletResponse response)  {
        oosService.download(fileName,response);
    }

    @DeleteMapping("/delete/{name}")
    public Result delete(@PathVariable("name") String fileName){
        return oosService.delete(fileName);
    }
}
